﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Gman.Entity.Entities;
using System.Collections.Generic;
using System.Web.Mvc;
using Gman.WebApp.ServiceControllers;
using System.Text;


namespace Gman.WebApp.Models
{
    public class BienModelValidator : ValidationBase
    {
        public List<KeyValuePair<string, string>> Validate(BienModel model)
        {
            BienModelValidator validator = new BienModelValidator();

            validator.RequiredFieldValidation("NroSerieBien", model.Bien.NroSerieBien, "Numero de Serie");
            validator.RequiredFieldValidation("DescBien", model.Bien.DescBien, "Descripcion");
            validator.RequiredFieldValidation("TipoBien", model.Bien.TipoBien, "Tipo Bien");
            validator.RequiredFieldValidation("IDSede", model.Bien.IDSede, "Sede");
            validator.RequiredFieldValidation("AreaBien", model.Bien.AreaBien, "Area Bien");
            validator.RequiredFieldValidation("NroGuiaRemiBien", model.Bien.NroGuiaRemiBien, "Nro Guia Remision Bien");

            return validator.ValidationList;
        }

        public static string BuildErrorMessage(List<KeyValuePair<string, string>> validationList)
        {
            StringBuilder sb = new StringBuilder(string.Empty);
            if (validationList.Count > 0)
                sb = new StringBuilder("Please fix the following error(s):");
            foreach (var validationError in validationList)
            {
                sb.Append("\n - ").Append(validationError.Value);
            }
            return sb.ToString();
        }
    }
}
